// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

// 登陆
var xhr = new XMLHttpRequest();
xhr.open('post', 'http://www.bmwenwo.com/index.php/PcApi/selectSession', true);
xhr.withCredentials = true;
xhr.send();
xhr.onload = function(r){
	if(!JSON.parse(xhr.response).user_id) window.location.href="http://www.bmwenwo.com/index.php/PcApi/login";
}

import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

import VueResource from 'vue-resource'
import h5Common from './assets/js/h5Common.js'
Vue.use(VueResource);
Vue.http.options.emulateJSON = true;
Vue.http.options.credentials = true;
// Vue.http.options.root = 'http://121.40.91.157/xwlt/php/index.php/PcApi';
Vue.http.options.root = 'http://www.bmwenwo.com/index.php/PcApi';
import './assets/lib/public.less'

import bus from './bus.js';
Vue.http.interceptors.push((request, next) => {
	// console.log(request)
	let obj = {
		isLoaded: false,
		keyXHR: Number(request.params)
	}
    bus.$emit('loading', obj);
    next((response) => {
    	obj.isLoaded = true;
    	// if(obj.isLoaded && obj.keyXHR) console.log(request.body)
        bus.$emit('loading', obj);
        return response
    });
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})
